package com.lxyk.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lxyk.pojo.Customer;
import com.lxyk.pojo.WaterDetails;
import com.lxyk.service.WaterDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/stat")
@Slf4j
public class WaterDetailsController {
    @Autowired
    private WaterDetailsService waterDetailsService;

    @RequestMapping("/statWaterDetails")
    public String listCust(@RequestParam(required = false,defaultValue = "1",value = "pageNum")Integer pageNum,
                           @RequestParam(defaultValue = "10",value = "pageSize")Integer pageSize, Model model, WaterDetails waterDetails){

        if (pageNum <= 0 || pageNum.equals("") || pageNum == null){
            pageNum = 1;
        }
        if (pageSize <= 0 || pageSize.equals("") || pageSize == null){
            pageSize = 10;
        }
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<WaterDetails> pageInfo = waterDetailsService.queryWaterDetails(waterDetails, pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "waterDetailsList";

    }

}
